import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns : BasicColumn[] = [
  {
    title: '模型名称',
    dataIndex: 'modelName'
  },
  {
    title: '模型类型',
    dataIndex: 'modelType_dictText'
  },
  {
    title: '模型字段',
    dataIndex: 'modelField'
  },
  {
    title: '数据类型',
    dataIndex: 'dataType_dictText'
  },
  {
    title: '数据单位',
    dataIndex: 'modelUnit'
  },
  {
    title: '模型描述',
    dataIndex: 'modelRemark'
  }
];

export const searchFormSchema : FormSchema[] = [
  {
    label: '模型类型',
    field: 'modelType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "model_type",
    },
  },
  {
    label: '模型名称',
    field: 'modelName',
    component: 'Input'
  },
];

//物模型------------
export const formSchema : FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'modelId', component: 'Input', show: false },
  { label: '', field: 'isEdit', component: 'InputNumber', show: false },
  {
    label: '模型名称',
    field: 'modelName',
    component: 'Input',
    rules: [{ required: true, message: "请输入模型名称" }],
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      console.log(values)
     if (values.isEdit != undefined && values.isEdit == true) {
       return true
     } else {
       return false
     }
    },
  },
  {
    label: '模型类型',
    field: 'modelType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "model_type",
    },
    rules: [{ required: true, message: "请选择模型类型" }],
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '模型字段',
    field: 'modelField',
    component: 'Input',
    rules: [{ required: true, message: "请输入模型字段" }],
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
     if (values.isEdit != undefined && values.isEdit == true) {
       return true
     } else {
       return false
     }
    },
  },
  {
    label: '数据类型',
    field: 'dataType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "data_type",
    },
    colProps: { span: 22 },
    rules: [{ required: true, message: "请选择数据类型" }],
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '数据单位',
    field: 'modelUnit',
    component: 'Input',
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '模型描述',
    field: 'modelRemark',
    component: 'Input',
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  }
];
